<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy       #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE CPP               #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Module      :  GHC.IO.StdHandles</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 2017</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Portability :  non-portable</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- This model abtracts away the platform specific handles that can be toggled</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- through the RTS.</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IO.StdHandles</span><span>
</span><span id="line-21"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="hs-comment">-- std handles</span><span>
</span><span id="line-22"></span><span>    </span><span class="annot"><a href="GHC.IO.StdHandles.html#stdin"><span class="hs-identifier">stdin</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.StdHandles.html#stdout"><span class="hs-identifier">stdout</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.StdHandles.html#stderr"><span class="hs-identifier">stderr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>    </span><span class="annot"><a href="GHC.IO.StdHandles.html#openFile"><span class="hs-identifier">openFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.StdHandles.html#openBinaryFile"><span class="hs-identifier">openBinaryFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.StdHandles.html#openFileBlocking"><span class="hs-identifier">openFileBlocking</span></a></span><span>
</span><span id="line-24"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.html"><span class="hs-identifier">GHC.IO</span></a></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.IOMode.html"><span class="hs-identifier">GHC.IO.IOMode</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html"><span class="hs-identifier">GHC.IO.Handle.Types</span></a></span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.IO.Handle.FD.html"><span class="hs-identifier">GHC.IO.Handle.FD</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">POSIX</span></span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.SubSystem.html"><span class="hs-identifier">GHC.IO.SubSystem</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Windows.html"><span class="hs-identifier">GHC.IO.Handle.Windows</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Win</span></span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="annot"><a href="GHC.IO.StdHandles.html#stdin"><span class="hs-identifier hs-type">stdin</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-36"></span><span id="stdin"><span class="annot"><span class="annottext">stdin :: Handle
</span><a href="GHC.IO.StdHandles.html#stdin"><span class="hs-identifier hs-var hs-var">stdin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="GHC.IO.Handle.FD.html#stdin"><span class="hs-identifier hs-var">POSIX.stdin</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Handle
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var">&lt;!&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="GHC.IO.Handle.Windows.html#stdin"><span class="hs-identifier hs-var">Win.stdin</span></a></span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="annot"><a href="GHC.IO.StdHandles.html#stdout"><span class="hs-identifier hs-type">stdout</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-39"></span><span id="stdout"><span class="annot"><span class="annottext">stdout :: Handle
</span><a href="GHC.IO.StdHandles.html#stdout"><span class="hs-identifier hs-var hs-var">stdout</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="GHC.IO.Handle.FD.html#stdout"><span class="hs-identifier hs-var">POSIX.stdout</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Handle
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var">&lt;!&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="GHC.IO.Handle.Windows.html#stdout"><span class="hs-identifier hs-var">Win.stdout</span></a></span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="annot"><a href="GHC.IO.StdHandles.html#stderr"><span class="hs-identifier hs-type">stderr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-42"></span><span id="stderr"><span class="annot"><span class="annottext">stderr :: Handle
</span><a href="GHC.IO.StdHandles.html#stderr"><span class="hs-identifier hs-var hs-var">stderr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="GHC.IO.Handle.FD.html#stderr"><span class="hs-identifier hs-var">POSIX.stderr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Handle
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var">&lt;!&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="GHC.IO.Handle.Windows.html#stderr"><span class="hs-identifier hs-var">Win.stderr</span></a></span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="annot"><a href="GHC.IO.StdHandles.html#openFile"><span class="hs-identifier hs-type">openFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.IOMode.html#IOMode"><span class="hs-identifier hs-type">IOMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-45"></span><span id="openFile"><span class="annot"><span class="annottext">openFile :: FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="GHC.IO.StdHandles.html#openFile"><span class="hs-identifier hs-var hs-var">openFile</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="GHC.IO.Handle.FD.html#openFile"><span class="hs-identifier hs-var">POSIX.openFile</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IOMode -&gt; IO Handle)
-&gt; (FilePath -&gt; IOMode -&gt; IO Handle)
-&gt; FilePath
-&gt; IOMode
-&gt; IO Handle
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var">&lt;!&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="GHC.IO.Handle.Windows.html#openFile"><span class="hs-identifier hs-var">Win.openFile</span></a></span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span class="annot"><a href="GHC.IO.StdHandles.html#openBinaryFile"><span class="hs-identifier hs-type">openBinaryFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.IOMode.html#IOMode"><span class="hs-identifier hs-type">IOMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-48"></span><span id="openBinaryFile"><span class="annot"><span class="annottext">openBinaryFile :: FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="GHC.IO.StdHandles.html#openBinaryFile"><span class="hs-identifier hs-var hs-var">openBinaryFile</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="GHC.IO.Handle.FD.html#openBinaryFile"><span class="hs-identifier hs-var">POSIX.openBinaryFile</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IOMode -&gt; IO Handle)
-&gt; (FilePath -&gt; IOMode -&gt; IO Handle)
-&gt; FilePath
-&gt; IOMode
-&gt; IO Handle
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var">&lt;!&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="GHC.IO.Handle.Windows.html#openBinaryFile"><span class="hs-identifier hs-var">Win.openBinaryFile</span></a></span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="annot"><a href="GHC.IO.StdHandles.html#openFileBlocking"><span class="hs-identifier hs-type">openFileBlocking</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.IOMode.html#IOMode"><span class="hs-identifier hs-type">IOMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-51"></span><span id="openFileBlocking"><span class="annot"><span class="annottext">openFileBlocking :: FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="GHC.IO.StdHandles.html#openFileBlocking"><span class="hs-identifier hs-var hs-var">openFileBlocking</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="GHC.IO.Handle.FD.html#openFileBlocking"><span class="hs-identifier hs-var">POSIX.openFileBlocking</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IOMode -&gt; IO Handle)
-&gt; (FilePath -&gt; IOMode -&gt; IO Handle)
-&gt; FilePath
-&gt; IOMode
-&gt; IO Handle
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var">&lt;!&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="GHC.IO.Handle.Windows.html#openFileBlocking"><span class="hs-identifier hs-var">Win.openFileBlocking</span></a></span><span class="hs-cpp">

#else
</span><span>
</span><span id="line-55"></span><span class="hs-identifier">stdin</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Handle</span><span>
</span><span id="line-56"></span><span class="hs-identifier">stdin</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">POSIX.stdin</span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-identifier">stdout</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Handle</span><span>
</span><span id="line-59"></span><span class="hs-identifier">stdout</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">POSIX.stdout</span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span class="hs-identifier">stderr</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Handle</span><span>
</span><span id="line-62"></span><span class="hs-identifier">stderr</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">POSIX.stderr</span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span class="hs-identifier">openFile</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FilePath</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IOMode</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Handle</span><span>
</span><span id="line-65"></span><span class="hs-identifier">openFile</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">POSIX.openFile</span><span>
</span><span id="line-66"></span><span>
</span><span id="line-67"></span><span class="hs-identifier">openBinaryFile</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FilePath</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IOMode</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Handle</span><span>
</span><span id="line-68"></span><span class="hs-identifier">openBinaryFile</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">POSIX.openBinaryFile</span><span>
</span><span id="line-69"></span><span>
</span><span id="line-70"></span><span class="hs-identifier">openFileBlocking</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FilePath</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IOMode</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Handle</span><span>
</span><span id="line-71"></span><span class="hs-identifier">openFileBlocking</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">POSIX.openFileBlocking</span><span class="hs-cpp">

#endif
</span></pre></body></html>